

import 'package:dio/dio.dart';
import 'package:get/get.dart';
import 'package:xin_nuo_pda/bean/user_entity.dart';
import 'package:xin_nuo_pda/http/http_config.dart';
import 'package:xin_nuo_pda/utils/request_util.dart';
import 'package:xin_nuo_pda/values/constant.dart';
import '../../bean/version_entity.dart';
import '../default_http_transformer.dart';
import '../http_client.dart';
import '../http_response.dart';
import '../version_http_transformer.dart';

class UserApi{
  static Future<HttpResponse<UserEntity>> login(CancelToken? cancelToken,{Map<String, dynamic>? params}) async {
    var response = await Get.find<HttpClient>().post<UserEntity>(
        'esbrest/RestService/postrequest',
      data: RequestUtil.formatJsonDataParameters(funcName:'SYS.USER_LOGIN',parame: params),
      cancelToken: cancelToken
    );
    return response;
  }

  static Future<AuthorityEntity?> authority({Map<String, dynamic>? params}) async {
    var response = await Get.find<HttpClient>().post<AuthorityEntity>(
      'esbrest/RestService/postrequest',
      data: RequestUtil.formatJsonDataParameters(funcName:'SYS.USER_GETAUTHORITY',parame: params)
    );
    return response.data;
  }

  static Future<String> checkUpdate(CancelToken? cancelToken,{dynamic params}) async {
    var response = await Get.find<HttpClient>().get(
        FILE_URL,
        cancelToken: cancelToken,
        httpTransformer : VersionHttpTransformer.getInstance(),
    );
    return response.data;
  }

}